
var g_floorNumTextData = [];

//绘制楼层号
function drawFloorNumCanvas(){
    creatFloorData();
    
    creatFloorNumText();
    
}
function creatFloorData(){
    
    if(g_bigFloorBoardMPolygons.children.length == 54)
    {
        for(var i = 0;i<g_bigFloorBoardMPolygons.children.length;i++)
        {
            var position = [];
            var temp = [];
            position.push(g_bigFloorBoardMPolygons.children[i].geometry.boundingSphere.center.x);
            position.push(g_bigFloorBoardMPolygons.children[i].geometry.boundingSphere.center.y);
            position.push(g_bigFloorBoardMPolygons.children[i].geometry.boundingSphere.center.z);
            temp.push(position);
            temp.push(g_bigFloorBoardMPolygons.children[i].name);
            g_floorNumTextData.push(temp);
        }
    }
}
function creatFloorNumText() {
    for(var i = 0;i<g_floorNumTextData.length;i++)
    {
        var floornum;
        if(getFloorNumFromNameId(g_floorNumTextData[i][1]) > 0)
        {
            floornum =  "F";
            floornum += getFloorNumFromNameId(g_floorNumTextData[i][1]);
        }
        else
        {
            floornum =  "B";
            floornum += -getFloorNumFromNameId(g_floorNumTextData[i][1]);
        }
        var sprite = new THREE.CanvasTexture( generateFloorNumText(floornum));
        var material = new THREE.SpriteMaterial( {
            map: sprite,
            blending: THREE.AdditiveBlending,
            depthTest:false,
            opacity:1
        } );

        var floorNumText = new THREE.Sprite( material );
        floorNumText.scale.x = floorNumText.scale.y = 40;

        var x = g_floorNumTextData[i][0][0];
        var y = -10;
        var z = g_floorNumTextData[i][0][2]-20;
        
        floorNumText.position.set(x,y,z);
        floorNumText.name = g_floorNumTextData[i][1];
        g_floorNumTextGroup.add(floorNumText);
        g_floorNumTextGroup.children[i].visible = false;
        
    }
    g_floorNumTextGroup.rotation.x = -0.5*Math.PI;
    g_floorNumTextGroup.rotation.z = -0.5*Math.PI;
    g_scene.add( g_floorNumTextGroup );
    

}
function generateFloorNumText(text) {
    var canvas = document.createElement( 'canvas' );
    canvas.width = 256;
    canvas.height = 256;

    var context = canvas.getContext( '2d' );
    context.beginPath();
    context.font='65px Microsoft YaHei';
    context.fillStyle = "white";
    context.fillText(text,0,50);
    context.fill();
    context.stroke();
    return canvas;
}
function floorTextPickShow(){
    
    for(var i = 0;i<g_floorNumTextGroup.children.length;i++)
    {
        if(getFloorNumFromNameId(g_floorNumTextGroup.children[i].name) !=
           getFloorNumFromNameId(g_recordSelectedMesh.name))
        {
            g_floorNumTextGroup.children[i].visible = false;
        }
        else
        {
            g_floorNumTextGroup.children[i].visible = true;
        }
    }
}
function floorTextShow(flag){
    for(var i = 0;i<g_floorNumTextGroup.children.length;i++)
    {
        g_floorNumTextGroup.children[i].visible = flag;
    }
}
